package helloworld.admin.action.teacher;

import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.apache.struts.action.ActionForm;
import org.apache.struts.action.ActionForward;
import org.apache.struts.action.ActionMapping;

import helloworld.admin.assembler.teacher.TeacherFormAssembler;
import helloworld.admin.bean.TeacherAdminBean;
import helloworld.admin.form.teacher.TeacherForm;
import helloworld.delegate.teacher.TeacherDelegate;
import org.apache.struts.actions.DispatchAction;

/** 
 * @author TUYEN-DM
 *         <p>
 *         2009/05/13
 *         </p>
 *         <p>
 *         TeacherShowAction is the object representation of showing teacher's form.
 *         </p>
 */
public class TeacherShowAction extends DispatchAction {
	
	public ActionForward Create(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
	throws Exception{
		return mapping.findForward("teacherFormPage");
	}
	
	public ActionForward Edit(ActionMapping mapping, ActionForm form,
			HttpServletRequest request, HttpServletResponse response)
	throws Exception{
		TeacherDelegate delegate = new TeacherDelegate();
		TeacherAdminBean teacher = delegate.getTeacherDetail(request.getParameter("teacherName"));
		TeacherForm custForm = TeacherFormAssembler.createTeacherForm(teacher);
		request.setAttribute("TeacherForm", custForm);
		return mapping.findForward("teacherFormPage");
	}
}
